#	-----------------------------------------------------------------------------------------
#   File Name:      drugwarmap.R                                                    
#   Author:         Omar García-Ponce and Thomas Zeitzoff                                   
#   Date:           June 27, 2020                                                 
#   Purpose:        Generate Figure 2 from "Are Voters too Afraid to Tackle Corruption?"                                                                                                                  
#   Machine:        Omar's MacBook Pro                                                
#	Software:         R
#	-----------------------------------------------------------------------------------------

rm(list=ls())

library(maptools)
library(RColorBrewer)
library(classInt)
library(rgdal)

# Change working directory here

mexico <- readOGR( 
  dsn= "MUNICIPIOS" , 
  layer="MUNICIPIOS",
  verbose=FALSE
)

names(mexico)

colours <- brewer.pal(5, "Reds") 

brks<-classIntervals(mexico$rkillings,  n=6, style="fixed",
                     fixedBreaks=c(0, 1, 10, 20, 50, 600))

plot(brks, pal=colours)

brks<- brks$brks

pdf('figure2.pdf')
plot(mexico, col=colours[findInterval(mexico$rkillings, brks, all.inside=TRUE)], axes=F)
dev.off()
